/*************************************************************************
 * Copyright 2008 David Almilli
 *  
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 *  
 *     http://www.apache.org/licenses/LICENSE-2.0 
 *      
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 **************************************************************************/
package com.tivo.hme.bananas;

import static com.tivo.hme.sdk.IHmeProtocol.*;

public class DefaultListRenderer implements ListRenderer {
    protected int leftInset = 10;
    protected int rightInset = 10;
    protected int topInset = 0;
    protected int bottomInset = 0;
    protected boolean shadowVisible = true;
    protected int flags = RSRC_HALIGN_LEFT;

    public void createRow(BListPlus list, BView parent, int index) {
        int x = getLeftInset();
        int y = getTopInset();
        int width = parent.getWidth() - x - getRightInset();
        int height = parent.getHeight() - y - getBottomInset();
        
        BTextPlus text = new BTextPlus(parent, x, y, width, height);
        text.setShadow(isShadowVisible());
        text.setFlags(getFlags());
        text.setFont(list.getFont());
        text.setColor(list.getColor());
        text.setValue(list.get(index));
    }

    public void disposeRow(BListPlus list, BView parent) {
    }

    public int getBottomInset() {
        return bottomInset;
    }

    public void setBottomInset(int bottomInset) {
        this.bottomInset = bottomInset;
    }

    public int getLeftInset() {
        return leftInset;
    }

    public void setLeftInset(int leftInset) {
        this.leftInset = leftInset;
    }

    public int getRightInset() {
        return rightInset;
    }

    public void setRightInset(int rightInset) {
        this.rightInset = rightInset;
    }

    public boolean isShadowVisible() {
        return shadowVisible;
    }

    public void setShadowVisible(boolean shadowVisible) {
        this.shadowVisible = shadowVisible;
    }

    public int getTopInset() {
        return topInset;
    }

    public void setTopInset(int topInset) {
        this.topInset = topInset;
    }

    public int getFlags() {
        return flags;
    }

    public void setFlags(int flags) {
        this.flags = flags;
    }
}
